package com.vstudy.web.service;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
 * Java 7 for循环实现 {@link SumService}
 */

@Profile("java7")  // 当jdk环境为java7时，Service注解生效
@Service
public class Java7SumServiceImpl implements SumService {
    @Override
    public Integer sum(Integer... values) {
        System.out.println("java 7的方式实现求和");
        Integer sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += values[i];
        }
        return sum;
    }
}
